<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" hrel="http://localhost/4.17/esri/css/main.css" />
    <script src="http://localhost/4.17/dojo/dojo.js"></script>
    <script src="js/jquery-2.0.3.min.js"></script>
    <!-- 引入layui框架 -->
    <link rel="stylesheet" href="js/layui/css/layui.css">
    <script src="js/layui/layui.js"></script>
    <!-- <script src="js/jsapi_vsdoc12_v38.js"></script> -->
    <style>
        html,
        body,
        #viewDiv {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
            d
        }
    </style>

    <script>
        require([
            "esri/Map",
            "esri/Basemap",
            "esri/views/MapView",
            "esri/views/SceneView",
            "esri/geometry/Extent",
            "esri/geometry/SpatialReference",
            //几何
            "esri/geometry/Point",
            "esri/geometry/Polyline",
            "esri/geometry/Polygon",
            "esri/Graphic",
            "esri/widgets/Sketch",
            "esri/Color",
            //切片地图信息
            "esri/layers/support/TileInfo",
            //图层
            "esri/layers/WebTileLayer",
            "esri/views/layers/LayerView",
            "esri/layers/TileLayer",
            "esri/layers/MapImageLayer",
            "esri/layers/FeatureLayer",
            "esri/layers/GraphicsLayer",
            //符号化
            "esri/symbols/SimpleMarkerSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/SimpleLineSymbol",
            //缓冲参数，用于GeometryService
            "esri/tasks/support/BufferParameters",
            //几何处理，投影、简化、缓冲区
            "esri/tasks/GeometryService",
            //几何引擎，用于测试、测量和分析两个或多个二维几何图形之间的空间关系,缓冲、修剪、距离、相交、联合、面积距离计算等。
            "esri/geometry/geometryEngine",
            //代理
            "esri/core/urlUtils",
            //查询
            "esri/tasks/FindTask",
            "esri/tasks/support/FindParameters",
            "esri/tasks/QueryTask",
            "esri/tasks/support/Query",
            "esri/tasks/IdentifyTask",
            "esri/tasks/support/IdentifyParameters",
            //打印地图
            "esri/tasks/PrintTask",
            "esri/tasks/support/PrintTemplate",
            "esri/tasks/support/PrintParameters",
            "dojo/dom",
            "dojo/on",
            "dojo/domReady!"
        ], function(
            Map,
            Basemap,
            MapView,
            SceneView,
            Extent,
            SpatialReference,
            Point,
            Polyline,
            Polygon,
            Graphic,
            Sketch,
            Color,
            TileInfo,
            WebTileLayer,
            LayerView,
            TileLayer,
            MapImageLayer,
            FeatureLayer,
            GraphicsLayer,
            SimpleMarkerSymbol,
            SimpleFillSymbol,
            SimpleLineSymbol,
            BufferParameters,
            GeometryService,
            urlUtils,
            FindTask,
            FindParameters,
            QueryTask,
            Query,
            IdentifyTask,
            IdentifyParameters,
            PrintTask,
            PrintTemplate,
            PrintParameters,
            dom,
            on) {
            var map = new Map({ //属性：allLayers、ground、layers
                basemap: "osm"
            });
            //创建一个MapView实例（用于2D查看）并引用该地图实例
            //为了使地图在DOM中对用户可见，必须创建一个MapView并至少引用两个对象：一个Map实例和一个DOM元素。分别在map和container属性中设置。
            var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 12,
                center: [120.370036, 36.096545] // longitude, latitude
            });
            var layer = new MapImageLayer({
                url: "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
            });
            map.add(layer);

            // var tracksSublayer = layer.allSublayers.find(function(sublayer) {
            //     //return sublayer.id === tracksId;
            //     console.log(sublayer);
            // });
            getLayer();

            function getLayer() {
                var v1 = layer.allSublayers.items;
                var v = layer.allSublayers;

                console.log(v);
                // layer.allSublayers.find(function(sublayer) {
                //     console.log(sublayer);
                // });
            }
        });
    </script>
</head>

<body>
    <div id="viewDiv"></div>
    <div style="background-color:yellow; height: 300px; width: auto; position: fixed;top: 0px; right: 30px;">
        <input type="text" value="请选择图层">
        <select id="selLayer">
        </select>
        <input type="text" value="请选择查询方式">
        <select id="selBy">
            <option value="属性">属性</option>
            <option value="名称">名称</option>
            <option value="日期">日期</option>
        </select><br>
        <input type="text" value="请输入">
        <select>
            <option value="属性"></option>
            <option value="名称"></option>
            <option value="日期"></option>
        </select>
    </div>
    <span id="testView"></span>
    <div id="test2"></div>
</body>

</html>
<script>
    var url = "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
    var length = 6;
    var opt = null;
    for (var i = 0; i < length; i++) {
        opt += "<option>" + i + "<option>"
    };
    $("#selLayer").append(opt);
    //获取选择的select值
    var selValue = $("selBy").find("option:selected").attr("value");
    console.log(selValue);
    if ($("selBy").find("option:selected").attr("value") == "日期") {

    }
</script>